package com.sutong.myinterface.controller;

import com.sutong.common.model.Person;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 名称 API
 *
 * @author sutong
 */
@RestController
@RequestMapping("/name")
public class PersonController {

    @GetMapping
    public String getNameByGet(String name, HttpServletRequest request) {
        return "GET 你的名字是" + name;
    }

    @PostMapping
    public String getNameByPost(@RequestParam String name) {
        return "POST 你的名字是" + name;
    }

    @PostMapping("/user")
    public String getUsernameByPost(@RequestBody Person person, HttpServletRequest request) {
        String result = "POST 用户名字是" + person.getUsername();
        return result;
    }
}
